public class zhangyuhan {
    public static void main(String[] args) {

        int a = 2;
        int n = 5;
        System.out.println("The sum of the series is: " + sumSeries(a, n));
    }

    public static long sumSeries(int a, int n) {
        long sum = 0;
        long term = 0; // 当前项的值
        for (int i = 1; i <= n; i++) {

            term = 0;
            for (int j = 0; j < i; j++) {
                term = term * 10 + a;
            }
            sum += term;
        }
        return sum;
    }
}
